import tkinter as tk

import windows.WindowsMain as WindowsMain
from Chara.SystemChara import FuLanDuoLu
from SubThread.AutoPlaceChart import AutoPlaceChara
from windows.SubWindows.SubWindow import SubWindow
from windows.SubWindows.SubWindowWidget import WidgetStyleConfig


class CharaView(SubWindow):
    def __init__(self, windows: WindowsMain, chara, thread_open=None):
        """
        DESCRIPT:
            角色能力详细页面

        @param windows: WindowsMain 类
        """
        windows.state = "人物角色详细页"
        self.window = windows
        if thread_open is not None:
            self.thread_place = AutoPlaceChara(windows, chara, callback=self.__init__)
            self.thread_place.openThread()

        self.titleWSC = WidgetStyleConfig
        self.chara = chara()
        self.sow, self.soc  = windows, chara

        self.titleWSC.text = "角色查看 " + self.chara.name
        self.img = self.chara.get_tkinter_image()

        self.rc = self.chara.errorRate
        self.mp = self.chara.multiplyingPower

        super().__init__(windows)



    def boxPack(self):


        self.SubWindowWidget.title(WidgetStyleConfig=self.titleWSC, position="center")
        # 标题的设置
        self.frame = self.SubWindowWidget.pack_sub_viewer()
        self.frame['bg'] = '#2B2B2B'
        wid, hei = self.window.win.winfo_height(), self.window.win.winfo_width()
        chart_size = ...

        self.power_img = self.chara.get_charts()

        self.window.win.update()
        self.showChart()
        self.window.win.update()


    def showChart(self):
        f_h,f_w = self.getFrameSize()
        print(f_h)
        chara_h = f_h
        chara_w = f_w*.21

        self.img = self.chara.get_tkinter_image(resize=(chara_w,chara_h))

        self.lable_pic_chara = tk.Label(self.frame, image=self.img)
        self.lable_pic_chart = tk.Label(self.frame, image=self.chara.get_charts(size=[f_w*.6, f_h*.6]))


        self.lable_pic_chara.place(relheight=1, relwidth=.21)
        print('w',f_w)
        print("x",f_w * 0.21 + 30)
        self.lable_pic_chart.place(relheight=.76, relwidth=.6, x= f_w *.21 + f_w * 0.79  / 10, y=f_h/7)


if __name__ == '__main__':
    ...
